The FSSA algorithm begins with the creation and visualization of functional time series data. The following is a univariate example which begins with the creation of functional data objects using the ‘fda’ package starting with call center data.
data("Callcenter")
require(fda)
require(Rfssa)
## Define functional objects
D <- matrix(sqrt(Callcenter$calls),nrow = 240)
N <- ncol(D)
time <- seq(ISOdate(1999,1,1), ISOdate(1999,12,31), by="day")
K <- nrow(D)
u <- seq(0,K,length.out =K)
d <- 22 #Optimal Number of basis elements
basis <- create.bspline.basis(c(min(u),max(u)),d)
Ysmooth <- smooth.basis(u,D,basis)
Next we convert the fd data object to an object of class functional time series.
## Define functional time series
Y <- fts(Ysmooth$fd,time = time)
The following plots can be used to visualize functional time series objects.
plot(Y, xlab = "Intraday intervals",ylab = "Sqrt of Callcenter", type='3Dsurface')
plot(Y, xlab = "Intraday intervals",ylab = "Sqrt of Callcenter", type='3Dline')
The FSSA algorithm also supports multivariate options. This bivariate example begins with the kernel density estimation of the distribution of pixel intensity in the Jambi NDVI and EVI data sets.
require(fda)
require(Rfssa)
## Raw image data
NDVI=Jambi$NDVI
EVI=Jambi$EVI
time <- Jambi$Date
## Kernel density estimation of pixel intensity
D0_NDVI <- matrix(NA,nrow = 512, ncol = 448)
D0_EVI <- matrix(NA,nrow =512, ncol = 448)
for(i in 1:448){
D0_NDVI[,i] <- density(NDVI[,,i],from=0,to=1)$y
D0_EVI[,i] <- density(EVI[,,i],from=0,to=1)$y
}
Next, we define the bivariate functional data object.
## Define functional objects
d <- 11
basis <- create.bspline.basis(c(0,1),d)
u <- seq(0,1,length.out = 512)
y_NDVI <- smooth.basis(u,as.matrix(D0_NDVI),basis)$fd
y_EVI <- smooth.basis(u,as.matrix(D0_EVI),basis)$fd
y=list(y_NDVI,y_EVI)
Then we convert the bivariate functional data object into a bivariate functional time series.
## Define functional time series
Y <- fts(y,time=time)
Now we visualize the multivariate functional time series using the following.
plot(Y, type = '3Dsurface', var=1,ylab = c("NDVI"),main = "Probability Kernel Density")
plot(Y, type = '3Dline', var=1,ylab = c("NDVI"),main = "Probability Kernel Density")
plot(Y, type = '3Dsurface', var=2,ylab = c("EVI"),main = "Probability Kernel Density")
plot(Y, type = '3Dline', var=2,ylab = c("EVI"),main = "Probability Kernel Density")
We do not include plot or heatmap options in any of the plots here for an example simply because Rmarkdown does not support those plots.